package net.optix.ip.commands
{
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import net.optix.ip.business.*;
	import net.optix.ip.events.SearchInventionsEvent;
	import net.optix.ip.model.ModelLocator;
	
	public class SearchInventionsCommand implements Command, Responder
	{
		// attributes ============================
		private var model : ModelLocator = ModelLocator.getInstance();


		// functions ============================
		public function execute( event:CairngormEvent ) : void
		{
			var myEvent:SearchInventionsEvent = SearchInventionsEvent( event );
			
			var delegate:SearchInventionsDelegate = new SearchInventionsDelegate( this );     
			delegate.getData( myEvent.keyWords );
			
		}
		
		//----------------------------------------------------------------------------
		public function onResult( event : * = null ) : void
		{
			//trace("event"+event.result);
			var inventions:XML	=	event.result;
			
			delete inventions.result;
			

			//trace(model.inventions);
		}
		
		//----------------------------------------------------------------------------
		public function onFault( event : * = null ) : void
		{
			model.result	=	"Program error";	
		}

	}
}